import 'package:dartx/dartx.dart';
import 'package:gluz/generated/json/base/json_field.dart';
import 'package:gluz/generated/json/user_vip_entity.g.dart';
import 'dart:convert';
export 'package:gluz/generated/json/user_vip_entity.g.dart';

@JsonSerializable()
class UserVipEntity {
	String id = '';
	String userId = '';
	String level = '0';
	int score = 0;
	int remainDays = 0;

	UserVipEntity();

	/// 获取过期时间
	String get expiredDateString {
		DateTime expiredDate = DateTime.now().add(Duration(days: remainDays));
		String year = expiredDate.year.toString().padLeft(4, '0'); // 2025
		String month = (expiredDate.month).toString().padLeft(2, '0'); // 09
		String day = (expiredDate.day).toString().padLeft(2, '0'); // 20
		String result = '$year-$month-$day';
		return result;
	}

	String get levelAssets {
		String levelString = level.isEmpty ? '0' : level;
		return 'assets/images/mine/mine_vip_flag_$levelString.png';
	}

	factory UserVipEntity.fromJson(Map<String, dynamic> json) => $UserVipEntityFromJson(json);

	Map<String, dynamic> toJson() => $UserVipEntityToJson(this);

	@override
	String toString() {
		return jsonEncode(this);
	}
}